import 'package:flutter/material.dart';

class Customscrollview extends StatelessWidget {
  const Customscrollview({super.key});

  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: [
        //轮播图
        SliverToBoxAdapter(
          child: Container(
            alignment: Alignment.center,
            height: 200,
            color: Colors.red,
            child: const Text('轮播图'),
          ),
        ),
        //间距
        SliverToBoxAdapter(
          child: Container(
            height: 10,
            color: Colors.grey,
          ),
        ),
        //宫格布局
        SliverGrid.builder(
          //宫格布局个数
          itemCount: 8,
          gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
            maxCrossAxisExtent: 120,
            //子组件间距
            mainAxisSpacing: 10,
            //子组件间距
            crossAxisSpacing: 10,
            //宽高比
            childAspectRatio: 1,
          ),
          itemBuilder: (context, index) {
            return Container(
              alignment: Alignment.center,
              height: 100,
              color: Colors.orange,
              child: Text('宫格$index'),
            );
          },
        ),
        //间距
        SliverToBoxAdapter(
          child: Container(
            height: 10,
            color: Colors.grey,
          ),
        ),
        //列表
        SliverList.separated(
          separatorBuilder: (context, index) {
            return const SizedBox(height: 5);
          },
          itemBuilder: (context, index) {
            return Container(
              height: 100,
              color: Colors.orange,
              alignment: Alignment.center,
              child: const Text('传智教育'),
            );
          },
          itemCount: 10,
        ),
      ],
    );
  }
}
